//
//  StatusRetweetedCell.swift
//  sinaWeiBo
//
//  Created by smartlei on 15/10/21.
//  Copyright © 2015年 smartlei. All rights reserved.
//
//继承StatusCell
import UIKit

class StatusRetweetedCell: StatusCell {
    //
    override var statusViewModel: StatusViewModel? {
        //监控属性值改变
        didSet {
            retweetedLabel.text = statusViewModel?.retweetedText ?? ""
            //更新retweetedLabel顶部布局
            retweetedLabel.snp_updateConstraints { (make) -> Void in
                //根据配图存在不调整顶部间距
                let offset = statusViewModel?.pic_urlsURL?.count > 0 ? StatusCellMargin : 0
                make.top.equalTo(midLable.snp_bottom).offset(offset)
            }
        }
    }
    
    //1 创建背景Btn
    private lazy var backBtn: UIButton = {
        
        let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.93, alpha: 1.0)
        return btn
    }()
    //2 懒加载转发Lable
    private lazy var  retweetedLabel: UILabel = UILabel(labText: "我转发的我转发的我转发的我转发的我转发的我转发的我转发的",
        labTextColor: UIColor.redColor(),//字体颜色
        fontSize: 13,//字体大小
        textInset: StatusCellMargin)//最大宽度
    //3
    

    

}

//MARK - 设置UI 
extension StatusRetweetedCell {
    override func setupUI() {
        super.setupUI()
        pictureView.backgroundColor = UIColor(white: 0.93, alpha: 1.0)
        //1 添加控件
        //contentView.addSubview(backBtn)
        //backBtn在pictureView下边
        contentView.insertSubview(backBtn, belowSubview: pictureView)
        
        //contentView.addSubview(retweetedLabel)
        contentView.insertSubview(retweetedLabel, aboveSubview: backBtn)
        
        //2 设置约束
        backBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(midLable.snp_bottom)
            
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            
            make.bottom.equalTo(pictureView.snp_bottom)
        }
        
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(midLable.snp_bottom)
            make.left.equalTo(contentView.snp_left).offset(StatusCellMargin)
            make.right.equalTo(contentView.snp_right).offset(-StatusCellMargin)
            
            
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom)
            make.left.equalTo(contentView.snp_left).offset(StatusCellMargin)

            //由于要采用更新的方式，所以建约束的时候宽高不要建参考,写个死值
            make.height.equalTo(150)
            make.width.equalTo(150)
        }

        
    }
    
}
